﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Org.BouncyCastle.Utilities.Encoders;

namespace Bitcoin.Test.TestData
{
    class Base58EncodeDecodeData : IEnumerable<TestCaseData>
    {
        public IEnumerator<TestCaseData> GetEnumerator()
        {
            var file = "TestData\\base58_encode_decode.json";
            JArray json;
            using (var tr = new StreamReader(file))
            {
                json = JArray.Parse(tr.ReadToEnd());
            }
            foreach (JArray data in json)
            {
                var hex = (string) data[0];
                var bytes = Hex.Decode(hex);
                var base58 = (string) data[1];
                yield return new TestCaseData(base58, bytes);
            }
        }

        //public IEnumerator<TestCaseData> GetEnumerator1()
        //{
        //    yield return new TestCaseData(new byte[] {}, string.Empty);
        //    yield return new TestCaseData(new byte[] {0x61}, "2g");
        //    yield return new TestCaseData(new byte[] {0x62, 0x62, 0x62}, "a3gV");
        //    yield return new TestCaseData(new byte[] {0x63, 0x63, 0x63}, "aPEr");
        //    yield return
        //        new TestCaseData(
        //            new byte[]
        //            {
        //                0x73, 0x69, 0x6d, 0x70, 0x6c, 0x79, 0x20, 0x61, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x73, 0x74,
        //                0x72, 0x69, 0x6e, 0x67
        //            }, "2cFupjhnEsSn59qHXstmK2ffpLv2");
        //    yield return
        //        new TestCaseData(
        //            new byte[]
        //            {
        //                0x00, 0xeb, 0x15, 0x23, 0x1d, 0xfc, 0xeb, 0x60, 0x92, 0x58, 0x86, 0xb6, 0x7d, 0x06, 0x52, 0x99,
        //                0x92, 0x59, 0x15, 0xae, 0xb1, 0x72, 0xc0, 0x66, 0x47
        //            }, "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L");
        //    yield return new TestCaseData(new byte[] {0x51, 0x6b, 0x6f, 0xcd, 0x0f}, "ABnLTmg");
        //    yield return
        //        new TestCaseData(new byte[] {0xbf, 0x4f, 0x89, 0x00, 0x1e, 0x67, 0x02, 0x74, 0xdd}, "3SEo3LWLoPntC");
        //    yield return new TestCaseData(new byte[] {0x57, 0x2e, 0x47, 0x94}, "3EFU7m");
        //    yield return
        //        new TestCaseData(new byte[] {0xec, 0xac, 0x89, 0xca, 0xd9, 0x39, 0x23, 0xc0, 0x23, 0x21},
        //            "EJDM8drfXA6uyA");
        //    yield return new TestCaseData(new byte[] {0x10, 0xc8, 0x51, 0x1e}, "Rt5zm");
        //    yield return
        //        new TestCaseData(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, "1111111111");
        //}

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
